package cn.zdxiang.jmjetpackmvvm

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter

/**
 * @author       Jm
 * @date         2020/7/21 11:41
 * @description
 */
class FragmentStateAdapter(context: Context, mutableList: MutableList<Fragment>) : FragmentStateAdapter(context as AppCompatActivity) {

    private var mFragments: MutableList<Fragment>? = null

    init {
        mFragments = mutableList
    }

    override fun getItemCount(): Int {
        return mFragments?.size!!
    }

    override fun createFragment(position: Int): Fragment {
        return mFragments!![position]
    }
}